#!/usr/bin/env ruby
# frozen_string_literal: true

lib_path = File.expand_path("../lib", __dir__)
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)

begin
  require "pry-byebug" if ENV["DIP_ENV"] == "debug"
rescue LoadError
  # do nothing
end

require "dip"
require "dip/cli"
require "dip/run_vars"

Signal.trap("INT") do
  warn("\n#{caller.join("\n")}: interrupted")
  exit(1)
end

begin
  Dip::CLI.start(ARGV)
rescue Dip::Error => e
  puts "ERROR: #{e.message}"
  exit 1
end
